package vn.personal.anhht.bloback12.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

public class PickContactActivity extends TabActivity {

    TabHost.TabSpec spec1, spec2, spec3;
    Resources rs;
    TabHost tabHost;
    Intent intentGetContact;
    Intent intentGetLogCall;
    Intent intentGetCustom;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        // LocalizationUtil.setupLanguage(getApplicationContext());

        super.onCreate(savedInstanceState);
        rs = getResources();
        setTitle(rs.getString(R.string.title_act_pick_contact));
        // Log.e("Create TAB", "Create TAB");

//        tabHost.addTab(tabHost
//                .newTabSpec("tab11")
//                .setIndicator(rs.getString(R.string.pick_titletab_contact),
//                        getResources().getDrawable(R.drawable.ic_contacts))
//                .setContent(
//                        new Intent(getApplicationContext(),
//                                TabPickContactActivity.class)));
//
//        tabHost.addTab(tabHost
//                .newTabSpec("tab12")
//                .setIndicator(rs.getString(R.string.pick_titletab_log),
//                        getResources().getDrawable(R.drawable.tab_call))
//                .setContent(
//                        new Intent(getApplicationContext(),
//                                TabPickLogActivity.class)));
//
//        tabHost.addTab(tabHost
//                .newTabSpec("tab13")
//                .setIndicator(rs.getString(R.string.pick_titletab_custom),
//                        getResources().getDrawable(R.drawable.ic_contact_new))
//                .setContent(
//                        new Intent(getApplicationContext(),
//                                TabPickCustomActivity.class)));
//        tabHost.setCurrentTab(0);
        setTabs();
    }
    
    /**
     * Sets the tabs.
     */
    private void setTabs() {
        tabHost = getTabHost();
        intentGetContact = new Intent(this, TabPickContactActivity.class);
        intentGetLogCall = new Intent(this, TabPickLogActivity.class);
        intentGetCustom = new Intent(this, TabPickCustomActivity.class);
        addTabs("Contact", R.drawable.ic_contacts,
                intentGetContact);
        addTabs("LogCall", R.drawable.tab_call,
                intentGetLogCall);
        addTabs("Custom", R.drawable.ic_contact_new,
                intentGetCustom);
    }

    /**
     * Adds the tabs.
     */
    public void addTabs(String label, int icon, Intent intent) {

        TabHost.TabSpec tabSpec = tabHost.newTabSpec("tab" + label);
        View tabIndicator = LayoutInflater.from(this).inflate(
                R.layout.tab_indocator, getTabWidget(), false);
        TextView title = (TextView) tabIndicator.findViewById(R.id.title);
        title.setText(label);
        ImageView icon1 = (ImageView) tabIndicator.findViewById(R.id.icon);
        icon1.setImageResource(icon);
        tabSpec.setIndicator(tabIndicator);
        tabSpec.setContent(intent);
        tabHost.addTab(tabSpec);
    }
}
